import request from './request'

/**
 * 发送消息
 */
export const sendMessage = (data) => {
  return request({
    url: '/chat/send',
    method: 'post',
    data
  })
}

/**
 * 获取会话列表
 */
export const getSessionList = () => {
  return request({
    url: '/chat/sessions',
    method: 'get'
  })
}

/**
 * 获取历史消息
 */
export const getMessageList = (params) => {
  return request({
    url: '/chat/messages',
    method: 'get',
    params
  })
}

/**
 * 标记消息为已读
 */
export const markMessagesAsRead = (sessionId) => {
  return request({
    url: `/chat/read/${sessionId}`,
    method: 'put'
  })
}

/**
 * 获取或创建会话
 */
export const getOrCreateSession = (otherUserId) => {
  return request({
    url: `/chat/session/${otherUserId}`,
    method: 'post'
  })
}

